﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Carrot.Core
{
    /// <summary>
    /// The implementation of Design By Contract principle.
    /// It does pre-condition check.
    /// </summary>
    public class Contract
    {
        /// <summary>
        /// Pre-conditional check the argument is not null
        /// </summary>
        /// <typeparam name="TArg">Type of argument</typeparam>
        /// <param name="argumentName">The name of argument be checked</param>
        /// <param name="argumentValue">The passed value of argument</param>
        /// <exception cref="ArgumentNullException"></exception>
        public static void CheckArgumentIsNotNull<TArg>(string argumentName, TArg argumentValue)
            where TArg : class
        {
            if (argumentValue == null)
                throw new ArgumentNullException(RS.ArgumentNullMessage, argumentName); 
        }
    }
}
